<?php
/**
 * Created by PhpStorm.
 * User: man0sions
 * Date: 16/8/29
 * Time: 上午10:30
 */

namespace src\base\api;

/**
 * Class Request
 * @package src\base\api
 * @author Luficer.p <81434146@qq.com>
 */
abstract class Request
{
    protected $url;
    protected $fetchStrategy;

    /**
     * Request constructor.
     * @param $url
     * @param FetchStrategy $fetchStrategy
     */
    function __construct($url,FetchStrategy $fetchStrategy)
    {
        $this->url = preg_replace("/&amp;/", "&", urldecode($url));
        $this->fetchStrategy = $fetchStrategy;
        $this->setOptions();
    }

    /**
     * @return mixed
     */
    function getUrl(){
        return $this->url;
    }

    /**
     * @return mixed
     */
    function fetch(){
        return $this->fetchStrategy->fetch($this);
    }

    /**
     * @return mixed
     */
    protected function setOptions(){
        return $this->fetchStrategy->setOptions($this);
    }



}